﻿using System;
using System.Drawing;
using System.Windows.Forms;

namespace Space_Conquest
{

    /// <summary>
    /// Holds Events Thrown by Form and Game Loop
    /// </summary>
    public class GameEvents
    {

        /// <summary>
        /// Renders on Form
        /// </summary>
        public static void Render()
        {


            // When Menus / Game Engine are implemented, this will be the only thing in this function:
            
            if (Globals.GameStack.Count > 0)
                Globals.GameStack.Peek().Render();
            

        }

        /// <summary>
        /// Motion comes from Timer Tick Event
        /// </summary>
        public static void Motion()
        {
            //GameObjects.TestSprite.Left++;

            // When Menus / Game Engine are implemented, this will be the only thing in this function:

            if (Globals.GameStack.Count > 0)
                Globals.GameStack.Peek().Motion();


        }

        /// <summary>
        /// Mouse Click Down Event
        /// </summary>
        /// <param name="button"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        public static void MouseDown(MouseButtons button, int x, int y)
        {

            // When Menus / Game Engine are implemented, this will be the only thing in this function:

            if (Globals.GameStack.Count > 0)
                Globals.GameStack.Peek().MouseDown(button, x, y);

        }

        /// <summary>
        /// Mouse Click Up Event
        /// </summary>
        /// <param name="button"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        public static void MouseUp(MouseButtons button, int x, int y)
        {

            // When Menus / Game Engine are implemented, this will be the only thing in this function:

            if (Globals.GameStack.Count > 0)
                Globals.GameStack.Peek().MouseUp(button,x,y);

        }

        /// <summary>
        /// Mouse Moved around screen
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        public static void MouseMove(int x, int y)
        {

            // When Menus / Game Engine are implemented, this will be the only thing in this function:

            if (Globals.GameStack.Count > 0)
                Globals.GameStack.Peek().MouseMove(x,y);

        }

        /// <summary>
        /// Key Pressed Down
        /// </summary>
        /// <param name="key"></param>
        /// <param name="shift"></param>
        public static void KeyDown(Keys key, bool shift)
        {

            if (key == Keys.Escape)
            {
                if (Globals.GameStack.Count > 1)
                {
                    Globals.iScreenOffsetX = 0;
                    Globals.iScreenOffsetY = 0;
                    Globals.GameStack.Pop();
                }
                else
                {
                    Globals.EndProgram();
                }
            }

            // When Menus / Game Engine are implemented, this will be the only thing in this function:

            if (Globals.GameStack.Count > 0)
                Globals.GameStack.Peek().KeyDown(key, shift);

        }

        /// <summary>
        /// Key Let Up
        /// </summary>
        /// <param name="key"></param>
        /// <param name="shift"></param>
        public static void KeyUp(Keys key, bool shift)
        {

            // When Menus / Game Engine are implemented, this will be the only thing in this function:

            if (Globals.GameStack.Count > 0)
                Globals.GameStack.Peek().KeyUp(key, shift);

        }

    }
}